<?php include_once('../control/page_top.php'); ?>
var firstload=false;
$(document).ready(function(){
	loadPage('news.php');
	//detechScrollDown();
});

function initPage(){
	//LV3
	$("#News_leftbar").removeClass("News_leftbar_animate").addClass('News_leftbar');
	//$("#News_leftbar").css("position", "fixed");
	$('#News_leftbar ul a').click(function(e) {
					e.preventDefault();
					$.scrollTo($(this).attr('href'), 700, {offset:-<?php echo $pagetopheight; ?>});
				});
}
function callBeforeAnimate(){
	$("#News_leftbar").removeClass("News_leftbar").addClass('News_leftbar_animate');
}
function loadPage(url){
	//LV2
	$.get(url, function(data){
		loadcontent(data);	
		initPage();
		if(url=='productlist.php'){
			$.getScript('js/productlist.php');
		}
     });
         
}

function loadcontent(data){
	//LV3
	if(firstload==false){
		$('#spaceholder1').html(data);
		firstload=true;
	}else{
		$('#spaceholder2').html(data).animate({left:'0px'}, 700);
		$("#News_leftbar").css("position", "relative");
		//callBeforeAnimate();
				//alert('-'+$('#spaceholder1').width()+'px');
			$('#spaceholder1').animate({left: '-'+$('#spaceholder1').width()+'px'}, {duration: 700, complete:function(){
				$("#spaceholder1").html(data);
				$("#spaceholder2").css('left', '1000px').html("");
				$('#spaceholder1').css('left', '0px');
				$('html, body').animate({scrollTop:0}, 10);
				initPage();
				
			}});	
		
		
	}	
}


